import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
import {GetRTDataByKKSCodesService} from '../../../services/get-rtdata-by-kkscodes.service'

@Component({
  selector: 'app-table-runninghour-status',
  templateUrl: './table-runninghour-status.component.html',
  styleUrls: ['./table-runninghour-status.component.css']
})
export class TableRunninghourStatusComponent implements OnInit,OnChanges {

  constructor(
    private getKksRes:GetRTDataByKKSCodesService
  ) { }


  statusList:object[] = []
  componentName:string = 'statusTable'

  // @Input() public totalKks:string;
  @Input() public level:string;
  @Input() public id:any;

  ngOnChanges(changes: SimpleChanges): void {
    // this.totalKks=changes['taotalKks']?changes['taotalKks'].currentValue:this.totalKks;
    this.fillTable();
  }

  private fillTable() {
    // this.getKksRes.getDataByComponent(this.componentName,this.level,this.id).subscribe(
    //   res=>{
    //     if(res.length===this.statusList.length){
    //       this.statusList.forEach((e,i)=>{
    //         e['value']=res[i];
    //       })
    //     }
    //   },
    //   error=>{
    //     console.log(error)
    //   }
    // )
  }
  ngOnInit() {
    this.statusList = [{
      'styleClass':'status-normal',
      'name':'事故停机',
      'value': 20
    },{
      'styleClass':'status-restrict-by-self',
      'name':'检修停机',
      'value': 20
    },{
      'styleClass':'status-restrict-by-dispatch',
      'name':'备用停机',
      'value':10
    },{
      'styleClass':'status-standby',
      'name':'满负荷',
      'value':10
    },{
      'styleClass':'status-stop-by-dispatch',
      'name':'调度限负荷',
      'value':30
    },{
      'styleClass':'status-stop-by-maintenance',
      'name':'设备限负荷',
      'value':30
    },{
      'styleClass':'status-stop-by-failure',
      'name':'现场运行',
      'value':0
    },{
      'styleClass':'status-disconnected',
      'name':'通讯中断',
      'value':0
    },];
    this.fillTable();
  }

}

